<div class="body-top">

	<div align="left">{$introduction nofilter}</div>

	{if $loggedIn != true}
	<div class="info-message"><p>Sign in with Hattrick above and press Update to get your coolness rating automatically!</p></div>
	{/if}
	{if $error !== null}
	<div class="error-message"><p>{$error}</p></div>
	{/if}
	{if $warning !== null}
	<div class="warning-message"><p>{$warning}</p></div>
	{/if}
	{if $loggedIn == true}
	<form action="{$action}#results" method="post" name="updaut">
		<input name="hidden" type="hidden" value="updaut"></input>
		<input name="rnd" type="hidden" value="{$rnd_maptrick}"></input>
	{else}
	<form action="{$action}#results" method="get" name="show">
	{/if}
    	<div align="left" style="margin-top: 10px;">TeamID:
			<input type="text" maxlength="7" class="team-box" name="team" value="{$teamID}"></input>		
		</div>
		{if $loggedIn == true}
		<input type="submit" class="updaut" value="Update"></input>
		{else}
		<input type="submit" class="updaut" value="Show"></input>
		{/if}				
	</form>
	<form action="{$action}#results" method="post" name="updman">
		<input name="hidden" type="hidden" value="updman"></input>
		<input name="rnd" type="hidden" value="{$rnd_maptrick}"></input>
		<input type="submit" class="updman_login" value="Update manually"></input>	

<table class="coolness">

	<tr>
		<th colspan="5"></th>
		<th colspan="7"><b>Active teams & users / Teams tendency</b></th>
		<th colspan="3" />
	</tr>
	<tr>
		<th><b>CD</b></th>
		<th><b>ND</b></th>
		<th align="left"><b>Country / English name</b></th>
		<th><b>Flag</b></th>
		<th><b>Season</b></th>
		<th><b>Teams</b></th>
		<th><b>Users</b><span class="wait"> +w</span></th>
		<th><b>T-1d</b></th>
		<th><b>T-1w</b></th>
		<th><b>T-8w</b></th>
		<th><b>T-16w</b></th>
		<th><b>T-32w</b></th>
		<th><b>Coolness</b></th>
		<th><b>A</b></th>
		<th><b>H</b></th>
	</tr>	
	
{foreach from=$coolnessTable item=row name=coolnessTable_loop}
	{assign var=country value=$row->getCountry()}
	<tr bgcolor="{$row->getColor()}">
		<td class="d{$country->getDivisions()}">{$country->getDivisions()}</td>
		<td class="d{$row->getNeededDivisions()}">{$row->getNeededDivisions()}</td>
		<td align="left">{$row->getRank()}. <a href="hallofcool.php?country={$country->getCountryID()}" title="Show the ranking for {$country->getName()}">{$country->getName()} / {$country->getEnglishName()}</a></td>
		<td align="center"><a class="flag" style="background-position: -{math equation='(x*y)' x=25 y=$country->getCountryID()}px 0px;" href="hallofcool.php?country={$country->getCountryID()}" title="Show the ranking for {$country->getName()}"></a></td>
		<td align="center">{$country->getSeasons()}</td>
		<td align="center">{$country->getActiveTeams()|number_format:0:".":" "}</td>
		<td align="center">{$country->getActiveUsers()|number_format:0:".":" "} <span class="wait">+{$country->getWaitingUsers()}</span></td>
		{if $row->getDay1() !== null}
			<td class="graph" bgcolor="{$row->getDay1_Color()}">
				{if $row->getDay1() > 0}+{/if}{$row->getDay1()}<br />
				{if $row->getDay1_Percentage() !== null}({if $row->getDay1() > 0}+{/if}{$row->getDay1_Percentage()}%)</td>
				{else}(Infinite)</td>				
				{/if}
		{else}
			<td />
		{/if}
		{if $row->getWeek1() !== null}
			<td class="graph" bgcolor="{$row->getWeek1_Color()}">
				{if $row->getWeek1() > 0}+{/if}{$row->getWeek1()}<br />
				{if $row->getWeek1_Percentage() !== null}({if $row->getWeek1() > 0}+{/if}{$row->getWeek1_Percentage()}%)</td>
				{else}(Infinite)</td>				
				{/if}
		{else}
			<td />
		{/if}
		{if $row->getWeek8() !== null}
			<td class="graph" bgcolor="{$row->getWeek8_Color()}">
				{if $row->getWeek8() > 0}+{/if}{$row->getWeek8()}<br />
				{if $row->getWeek8_Percentage() !== null}({if $row->getWeek8() > 0}+{/if}{$row->getWeek8_Percentage()}%)</td>
				{else}(Infinite)</td>				
				{/if}
		{else}
			<td />
		{/if}
		{if $row->getWeek16() !== null}
			<td class="graph" bgcolor="{$row->getWeek16_Color()}">
				{if $row->getWeek16() > 0}+{/if}{$row->getWeek16()}<br />
				{if $row->getWeek16_Percentage() !== null}({if $row->getWeek16() > 0}+{/if}{$row->getWeek16_Percentage()}%)</td>
				{else}(Infinite)</td>				
				{/if}
		{else}
			<td />
		{/if}
		{if $row->getWeek32() !== null}
			<td class="graph" bgcolor="{$row->getWeek32_Color()}">
				{if $row->getWeek32() > 0}+{/if}{$row->getWeek32()}<br />
				{if $row->getWeek32_Percentage() !== null}({if $row->getWeek32() > 0}+{/if}{$row->getWeek32_Percentage()}%)</td>
				{else}(Infinite)</td>				
				{/if}
		{else}
			<td />
		{/if}
		<td align="right">{$country->getCoolness()|number_format:2:".":" "}</td>
		<td><input type="checkbox" name="away[{$country->getCountryID()}]" value="true" {if $row->hasVisited() == true}checked="checked"{/if}/></td>
		<td><input type="checkbox" name="home[{$country->getCountryID()}]" value="true" {if $row->hasHosted() == true}checked="checked"{/if}/></td>
	</tr>
{/foreach}

</table>

	<input type="submit" class="updman" value="Update manually"></input>

</form>

{if $results == true}
<a name="results"></a>
<div class="results">
	<div class="box">
		<div class="box-title">
			{if $delete == true}
			<form action="{$action}" method="post" name="delete">			
				<input name="hidden" type="hidden" value="delete"></input>
				<input name="rnd" type="hidden" value="{$rnd_maptrick}"></input>
				<input type="submit" class="delete" value="" alt="Delete your team" title="Delete your team from the database if the flags aren't correct. ATTENTION: This removes your team from the Hall of Cool as well! You can add your team again by updating it here on the coolness page."></input>
			</form>
			{/if}
			<div class="title-16">Coolness rating {$teamname}</div>
		</div>
		<div class="box-inside">
			<div class="results-text">
				<div class="title-14">{$summary_title}</div>
				<table class="coolness">
					<tr>
						<th />
						<th colspan="2"><b>Flags</b></th>
						<th colspan="2"><b>Coolness</b></th>
						<th colspan="2"><b>Countries</b></th>
					</tr>
						<tr>
							<th><b>Type</b></th>
							<th><b>Number</b></th>
							<th><b>% of total<sup class="footnote">1</sup></b></th>
							<th><b>Score</b></th>
							<th><b>% of total<sup class="footnote">2</sup></b></th>
							<th><b>Rarest flag</b></th>
							<th><b>% of score<sup class="footnote">3</sup></b></th>
						</tr>
						<tr>
							<td>visited</td>
							<td align="right">{$away_flags}</td>
							<td align="right">{$away_flags_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$away_coolness|number_format:2:".":" "}</td>
							<td align="right">{$away_coolness_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$away_rarest}</td>
							<td align="right">{$away_rarest_percentage|number_format:2:".":" "} %</td>
						</tr>
						<tr>
							<td>hosted</td>
							<td align="right">{$home_flags}</td>
							<td align="right">{$home_flags_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$home_coolness|number_format:2:".":" "}</td>
							<td align="right">{$home_coolness_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$home_rarest}</td>
							<td align="right">{$home_rarest_percentage|number_format:2:".":" "} %</td>
						</tr>
						<tr>
							<td>visited AND hosted</td>
							<td align="right">{$and_flags}</td>
							<td align="right">{$and_flags_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$and_coolness|number_format:2:".":" "}</td>
							<td align="right">{$and_coolness_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$and_rarest}</td>
							<td align="right">{$and_rarest_percentage|number_format:2:".":" "} %</td>
						</tr>
						<tr>
							<td>visited OR hosted</td>
							<td align="right">{$or_flags}</td>
							<td align="right">{$or_flags_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$or_coolness|number_format:2:".":" "}</td>
							<td align="right">{$or_coolness_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$or_rarest}</td>
							<td align="right">{$or_rarest_percentage|number_format:2:".":" "} %</td>
						</tr>
						<tr>
							<td>visited PLUS hosted</td>
							<td align="right">{$plus_flags}</td>
							<td align="right">{$plus_flags_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$plus_coolness|number_format:2:".":" "}</td>
							<td align="right">{$plus_coolness_percentage|number_format:2:".":" "} %</td>
							<td align="right">{$plus_rarest}</td>
							<td align="right">{$plus_rarest_percentage|number_format:2:".":" "} %</td>
						</tr>
				</table>
			</div>
			
			<a name="maps"></a>
			<div class="title-14">{$map_title}</div>
			<div class="maps"><img id="map" src="map/coolmap.php?legend=true" alt="Map"/><br /></div>
			<div align="right"><a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=true&amp;special=true'">Default with legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=false&amp;special=true'">Default without legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=true&amp;special=false'">Detailed with legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=false&amp;special=false'">Detailed without legend</a></div>
			
			{if $showHoC == true}
			<div class="results-text">
				<div class="title-14">Ranks in Hall of Cool</div>
				<div>Click <a class="read-more" href="./coolness_hoc.php?team={$teamID}" rel="#overlay">here</a> to display the rankings of {$teamname} in the Hall of Cool. Loading might take very long!</div>
				
				<div class="overlay" id="overlay">
					<div class="wrap"></div>
				</div>
			</div>

			{literal}
			<script type="text/javascript">
				$(function() {
					$("a[rel]").overlay({
						expose: {
							color: '#CCCCCC',
							opacity: 0.8,
							closeSpeed: 1000
						},
						onBeforeLoad: function() {
							var wrap = this.getContent().find("div.wrap");
							if (wrap.is(":empty")) {
								wrap.load(this.getTrigger().attr("href"));
							}
						}
					});
				});
			</script>
			{/literal}
			{/if}
			
			<div class="results-text">
				<div class="title-14">{$forum_title}</div>
				<div>Click in a textarea and copy &amp; paste into Hattrick forum</div>
				<div class="results-left">
					<div><b>Played countries:</b></div>
					<div><textarea onclick="this.focus();this.select()" class="forum-box" rows="6" cols="58" name="played_text" readonly="readonly">{$played}</textarea></div>
				</div>
				<div class="results-right">
					<div><b>Missing countries:</b></div>
					<div><textarea onclick="this.focus();this.select()" class="forum-box" rows="6" cols="58" name="missing_text" readonly="readonly">{$missing}</textarea></div>
				</div>			
			</div>
			
			<div align="left">{$explanation nofilter}</div>
			
		</div>
	</div>
</div>
{/if}
	
</div>